
using System;
using System.Threading;
using System.Text;
using IrrlichtNETCP;
using IrrlichtNETCP.Extensions;
using GLib;
using Gtk;

namespace kinematix
{

	public class kApplication
	{
		
		public string pwd;
		
		kHTMLView lab_view;
		kPythonEditor editor;
		kToolWindow tool_win;
		kRenderer render;
		kPythonInterpreter python;
	
		
		/// this threading fucks up all the stuff so I'll comment it for a while
		/*public void PythonThreadMain()
		{
			python = new kPythonInterpreter(this);
		}
		
 		public void PythonStart()
		{
			System.Threading.Thread thr = new System.Threading.Thread(PythonStart);
			thr.Start();
		}*/
		
		
		/*public void RendererStart()
		{
			System.Threading.Thread thr = new System.Threading.Thread(RendererThreadMain);
			thr.Start();
		}	
		
		public void RendererThreadMain()
		{
			render = new kRenderer();
			render.Run();
			Quit();
		}*/
		
		public void GtkThreadStart()
		{
			System.Threading.Thread thr = new System.Threading.Thread(GtkThreadMain);
			thr.Start();
		}
		
 		public void GtkThreadMain()
		{
			Application.Init();

			//tool_win = new kToolWindow(this);			
			lab_view = new kHTMLView(this);
			
			Application.Run();	
		}
		
		public kApplication()
		{
		
			Console.WriteLine("Kinematix v0.1 alpha");
				pwd = System.IO.Path.GetDirectoryName(System.Environment.CommandLine);
			python = new kPythonInterpreter(this);			
		
			GtkThreadStart();			
			//RendererStart();
			render = new kRenderer(python);

			python.SetupGlobals(this, render);

			render.Run();
			Quit();		
//			PythonStart();
       
					
			
		}
				
		/*
		*	Запуск
		*/
		public static void Main()
		{
			new kApplication();
		}
		
		public void Quit()
		{
			Renderer.Quit();
			Application.Quit();
		}
	
		/*
		*	Обработчик событий
		*/

		public string CurrentDir
		{
			get
				{
					return pwd;
				}
		}
		
		public kRenderer Renderer
		{
			get{
				return render;
			}
		}
		
		public kPythonInterpreter PythonEngine
		{
			get{
				return python;
			}
		}
		
	}
	
}
